﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="EZCRS.HCMS.Web.manage.AIR.notify_list" Codebehind="notify_list.aspx.cs" %>

<%@ Register Src="../usercontrol/titlepage.ascx" TagName="titlepage" TagPrefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script src="../../common/jquery-1.2.6.min.js"></script>

    <script src="../../common/jquery-impromptu.1.5.js"></script>

    <script src="../../common/flexigrid/flexigrid.js"></script>

    <script src="../../common/query-2_1_7.js"></script>

    <script src="../../common/winbox.js"></script>

    <link rel="stylesheet" href="../../common/flexigrid/flexigrid.css" type="text/css"
        media="screen" />
    <link rel="stylesheet" href="../../style/dfbDialog.css" type="text/css" media="screen" />
    <style>
        #status
        {
            color: Red;
            font-weight: bold;
            margin: 5px 0 5px 0;
        }
    </style>
</head>
<body>

    <script type="text/javascript" charset="utf-8">

        var sending = false;

        $(document).ready(function() {

            $('#grid').flexigrid({
                //width: $(document).width() - 10,
                height: 350,
                //striped:false,		        
                url: '?action=get',
                dataType: 'json',
                colModel: [
		            { display: '编号', name: 'id', width: 100, sortable: false, align: 'left' },
                    { display: '名称', name: 'name', width: 300, sortable: false, align: 'left' },
                    { display: '创建日期', name: 'create', width: 180, sortable: false, align: 'left' }
                ],

                singleSelect: true,

                buttons: [
                    { name: '<%= Resources.Site.CreateRateNotify %>', onpress: doCommand, bclass: 'add' },
                    { name: '<%= Resources.Site.LabSendEmail %>', onpress: doCommand, bclass: 'send' },
                    { name: '<%= Resources.Site.LabSendFax %>', onpress: doCommand, bclass: 'fax' },
                    { name: '<%= Resources.Site.LabDelete %>', onpress: doCommand, bclass: 'delete' },
                    { name: '<%= Resources.Site.LabPrint %>', onpress: doCommand, bclass: 'print' },
                    { separator: true }
                ],

                showTableToggleBtn: true,
                rp: 15,
                usepager: true,
                useRp: true,
                onSuccess: onDoubleClick

            });

            $('#btnsearch').click(function() {

                var params = $("#txtName").val();

                $('#grid').flexOptions({ query: params }).flexReload();

            });

        });


        function onDoubleClick() {
            $('#grid tbody tr td').each(function() {
                $(this).dblclick(function(e) {
                    var row = $(this).parents('tr');
                    var id = row.children('td').eq(0).children('div').get(0).innerHTML;
                    ShowBox('notify_preview.aspx?id=' + id, 450);
                });
            });
        }

        function doCommand(com, grid) {

            if (com == '<%= Resources.Site.CreateRateNotify %>') {
                window.location = 'add_notify.aspx';
                return;
            }

            if ($('.trSelected', grid)[0] == null) {
                alert("<%= Resources.Site.NoItemSelected %>");
                return;
            }

            var rowid = $('.trSelected', grid)[0].id.replace(/row/, "");

            if (com == '<%= Resources.Site.LabDelete %>') {
                //delete
                if (rowid != '') {

                    if (confirm("<%= Resources.Site.SystemConfirmDelete %>")) {
                        var data = { id: rowid };
                        $.post("?action=del", data,
                                function(data, state) {
                                    doRefresh();
                                }, "json");
                    }
                }

            }
            else if (com == '<%= Resources.Site.LabPrint %>') {
                window.open('notify_preview.aspx?id=' + rowid);
            }
            else if (com == '<%= Resources.Site.LabSendEmail %>' || com == '<%= Resources.Site.LabSendFax %>') {

                $('#status').hide(500);
                if (sending) {
                    alert('正在发送中，请稍候再试！');
                    return;
                }

                var proto = 'fax';
                if (com == '<%= Resources.Site.LabSendEmail %>')
                    proto = 'email';

                var url = location.search;
                var chl = $.query.get('chl');
                var iata = $.query.get('iata');

                if (chl == "" && iata == "") {
                    if (confirm('还没有选择渠道或TA，是否现在转入渠道列表?'))
                        window.location = "../ta/channel_list.aspx";
                    return;

                }

                if (confirm("<%= Resources.Site.ScriptConfirm %>")) {
                    if (rowid != '') {
                        var data = { id: rowid };
                        sending = true;
                        $.post(window.location.search + "&action=send&p=" + proto, data,
                            function(data, state) {
                                sending = false;
                                $('#status').text('Sending now...');
                                if (data.rows > 0)
                                    $('#status').text("成功发送" + data.rows + "条信息！");
                                else
                                    $('#status').text("发送失败！");
                                $('#status').show(500);
                            },
                            "json");
                    }
                }

            }
        }

        function doRefresh() {
            $('#grid').flexOptions().flexReload();
        }
        

    </script>

    <form id="form1" runat="server">
    <uc2:titlepage ID="Titlepage1" runat="server" inittitle="<%$ Resources:Site, AIRNotifyList %>">
    </uc2:titlepage>
    </form>
 
 
                    <table border="0" align="center" cellpadding="0" cellspacing="0" class="main-table">
                        <tr>
                            <th class="minfo-title">
                                查询
                            </th>
                        </tr>
                        <tr>
                            <td>
                                通知标题：
                                <input id="txtName" type="text" class="text-line" />
                                <input id="btnsearch" type="button" value="<%= Resources.Site.LabSearch %>" class="bttn" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                        </tr>
                    </table>
             
 <br />
    <table id="grid">
    </table>
    <label id="status">
    </label>
    <div id="loadinfo" align="center">
    </div>
</body>
</html>
